// Copyright (c) 2002 Cunningham & Cunningham, Inc.
// Released under the terms of the GNU General Public License version 2 or later.

package eg.music
{

import com.fit4as.fit.*;

public class Browser extends Fixture {


    // Library //////////////////////////////////

    public function library(path : String) : void {
        //t race("Browser#library " + path );
        //library has been loaded in advance since ActionScript 
        //does not load asynchronously
        //MusicLibrary.instance.load( path );
    }

    public function totalSongs() : int {
        //t race("Browser#library " + MusicLibrary.instance.library.length );
        return MusicLibrary.instance.library.length;
    }

    // Select Detail ////////////////////////////

    public function playing() : String {
        return MusicPlayer.playing.title;
    }

    public function select(i : int) : void {
        //t race("Browser#select " + [ i, MusicLibrary.instance.library[i-1]]);
        MusicLibrary.instance.select(MusicLibrary.instance.library[i - 1]);
    }

    public function title() : String {
        //t race("Browser#title " + MusicLibrary.instance );
        //t race("Browser#title " + MusicLibrary.instance.looking );
        //t race("Browser#title " + MusicLibrary.instance.looking.title );
        return MusicLibrary.instance.looking.title;
    }

    public function artist() : String {
        return MusicLibrary.instance.looking.artist;
    }

    public function album() : String {
        return MusicLibrary.instance.looking.album;
    }

    public function year() : int {
        return MusicLibrary.instance.looking.year;
    }

    public function time() : Number {
        return MusicLibrary.instance.looking.time();
    }

    public function track() : String {
        return MusicLibrary.instance.looking.track();
    }

    // Search Buttons ///////////////////////////

    public function sameAlbum() : void {
        MusicLibrary.instance.findAlbum(MusicLibrary.instance.looking.album);
    }

    public function sameArtist() : void {
        MusicLibrary.instance.findArtist(MusicLibrary.instance.looking.artist);
    }

    public function sameGenre() : void {
        MusicLibrary.instance.findGenre(MusicLibrary.instance.looking.genre);
    }

    public function sameYear() : void {
        MusicLibrary.instance.findYear(MusicLibrary.instance.looking.year);
    }

    public function selectedSongs() : int {
        return MusicLibrary.instance.displayCount();
    }

    public function showAll() : void {
        MusicLibrary.instance.findAll();
    }

    // Play Buttons /////////////////////////////

    public function play() : void {
        MusicPlayer.play(MusicLibrary.instance.looking);
    }

    public function pause() : void {
        MusicPlayer.pause();
    }

    public function status() : String {
        return Music.status;
    }

    public function remaining() : Number {
        return MusicPlayer.minutesRemaining();
    }

}
}